<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements JWTSubject
{
    use Notifiable,SoftDeletes;

    protected $table = 'user';

    protected $fillable = [
        'nickname',
        'avatar_url',
        'phone',
        'user_role_ids',
        'now_role_id',
        'user_auth_id',
        'menus_auth_id',
        'username',
        'password',
        'status',
        'street_id',
        'village_id',
        'project_id',
        'segment_id',
        'grid_group_id',
        'id_obverse_img',
        'id_reverse_img',
        'signatures_img',
        'apply_img',
        'apply_status',
        'openid',
        'session_key',
        'unionid',
    ];

    // Rest omitted for brevity

    /**
     * Get the identifier that will be stored in the subject claim of the JWT.
     *
     * @return mixed
     */
    public function getJWTIdentifier()
    {
        return $this->getKey();
    }

    /**
     * Return a key value array, containing any custom claims to be added to the JWT.
     *
     * @return array
     */
    public function getJWTCustomClaims()
    {
        return [];
    }

    public function user_role()
    {
        return $this->hasOne(UserRole::class, 'id', 'now_role_id');
    }
}

